package com.movie;

import com.facebook.react.ReactActivity;
import com.movie.module.SharePackage;
import com.movie.module.ShareModule;

import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.util.Config;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;

import java.lang.reflect.Field;

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "Movie";
    }
    //分享相关
    @Override
    protected void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);
      ShareModule.initActivity(this);

    }
    public void setHideVirtualKey(Window window){
        //保持布局状态
        int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE|
                //布局位于状态栏下方
                View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION|
                //全屏
                View.SYSTEM_UI_FLAG_FULLSCREEN|
                //隐藏导航栏
                View.SYSTEM_UI_FLAG_HIDE_NAVIGATION|
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
        if (Build.VERSION.SDK_INT>=19){
            uiOptions |= 0x00001000;
        }else{
            uiOptions |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
        }
        window.getDecorView().setSystemUiVisibility(uiOptions);
    }
    public void hideView(){
        if (Build.VERSION.SDK_INT >= 19) {
            View decorView = getWindow().getDecorView();
            /*decorView.setSystemUiVisibility(
                    //状态栏和Activity共存，Activity不全屏显示。也就是应用平常的显示画面
                //View.SYSTEM_UI_FLAG_VISIBLE
                View.SYSTEM_UI_FLAG_LOW_PROFILE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION //应用的主体内容占用系统导航栏的空间
                //| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN  //应用的主体内容占用系统状态栏空间
                //| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION  //导航栏隐藏
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                |View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                );
                */
            //保持布局状态
            int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE|
                    //布局位于状态栏下方
                    //View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION|
                    //全屏
                    View.SYSTEM_UI_FLAG_FULLSCREEN|
                    //隐藏导航栏
                    View.SYSTEM_UI_FLAG_HIDE_NAVIGATION|
                    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
            if (Build.VERSION.SDK_INT>=19){
                uiOptions |= 0x00001000;
            }else{
                uiOptions |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
            }
            getWindow().getDecorView().setSystemUiVisibility(uiOptions);
        }
    }
    /*
    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        if (hasFocus && Build.VERSION.SDK_INT >= 19) {
            View decorView = getWindow().getDecorView();
            decorView.setSystemUiVisibility(
                    //状态栏和Activity共存，Activity不全屏显示。也就是应用平常的显示画面
                //View.SYSTEM_UI_FLAG_VISIBLE
                View.SYSTEM_UI_FLAG_LOW_PROFILE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION //应用的主体内容占用系统导航栏的空间
                //| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN  //应用的主体内容占用系统状态栏空间 
                //| View.SYSTEM_UI_FLAG_LAYOUT_STABLE  
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION  //导航栏隐藏
                | View.SYSTEM_UI_FLAG_FULLSCREEN   //Activity全屏显示，且状态栏被覆盖掉
                |View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                );

            decorView.setSystemUiVisibility(
                 View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }
    }*/


}
